package cn.laixueit.controller;

import cn.laixueit.pojo.ListVo;
import cn.laixueit.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Arrays;

@Controller
@RequestMapping("/student")
public class StudentController {

    @RequestMapping(value = "/testarr",method = RequestMethod.POST)
    public void testArr(Integer ids[], Model model){
        model.addAttribute("ids",ids);
        System.out.println(Arrays.toString(ids));
    }


    @RequestMapping("/testbean")
    public void testbean(User user){
        System.out.println(user);
    }

    @RequestMapping("/testbase")
    public String testbase(@RequestParam(name = "a",defaultValue = "root",required = false) String name){
        System.out.println(name+"取数据查询");
        return "index";
    }

    @RequestMapping("/testList")
    public void testList(ListVo listVo){
        for (User user : listVo.getUsers()) {
            System.out.println(user);
        }
    }


    @RequestMapping("/testMap")
    public void testMap(ListVo listVo){
        for (String key : listVo.getMapuser().keySet()) {
            System.out.println(listVo.getMapuser().get(key));
        }
    }


}
